<?php
class Resume_Plugin_MyResume extends Resume_Plugin_Abstract
{
    //获得每个区块的显示隐藏情况
    public static function  getAreaHideValueArr(ME_Request $input, ME_Response $output){
        $resumeDb = Db_Resume::instance();
	$eid = $input->eid;
	if($eid){
        	$sql = "select * from e_resume_areapos where eid = ".$eid;
	}else{
        	$sql = "select * from resume_areapos where uid = ".$input->uid;
	}
        return $resumeDb->getRow($sql);
    }
    public static function getBaseInfo(ME_Request $input, ME_Response $output)
    {
        $resumeDb = Db_Resume::instance();
        $sql = "select * from resume_baseInfo where uid ={$input->uid} ";
	$output->BaseData =
        $dataInfo = $output->dataInfo = $resumeDb->getRow($sql);
        //获得头像
        $output->avatar = Libs_UcUser::getAvatar(array('uid'=>$input->uid,'size'=>'middle') );
	$output->PhotoData = Libs_UcUser::checkAvatar($input->uid);
        //获得用户基本信息
        $output->userUcInfo = Libs_UcUser::getUserInfo(array('nameOrId'=>$input->uid,'flag'=>'1'));
        //获得地区信息
        $cityIds = implode(",",array($dataInfo['birthCity'],$dataInfo['regCity']));
        $privIds = implode(",",array($dataInfo['birthProv'],$dataInfo['regProv']));
        //$cityArr = Libs_Admin_Module::getModuleList(array('moduleId'=>1,'id'=>$areaIds));
        //取得省份
        $privArr = Libs_Admin_Category::getCategoryList(array('module_type'=>1,'id'=>$privIds,'type'=>1,'pagesize'=>1000));
        //取得城市
        $cityArr = Libs_Admin_Category::getCategoryList(array('module_type'=>1,'id'=>$cityIds,'type'=>2,'pagesize'=>1000));

        $tmpCityArr = array();
        if($cityArr){
            foreach($cityArr as $c){
                $tmpCityArr[$c['subclassid']] = $c['name'];
            }
        }

        $tmpPrivArr = array();
        if($privArr){
            foreach($privArr as $c){
                $tmpPrivArr[$c['classid']] = $c['name'];
            }
        }
        $output->cityArr = $tmpCityArr;
        $output->privArr = $tmpPrivArr;
        if('preView' == $output->pageType ){
             return $output->fetchCol('Plugin/MyResume/Preview/BaseInfo');
        }else{
             return $output->fetchCol('Plugin/MyResume/BaseInfo');
        }
    }

    public static function getEduInfo(ME_Request $input, ME_Response $output)
    {

        $resumeDb = Db_Resume::instance();
        $commonOption = array(
                'db'        => $resumeDb,
                'fromSql'   => 'from resume_edu',
                'whereSql'  => "where uid = {$input->uid}",
                'onlyData'  => true,
                'debug'     => false,
        );
        $output->eduList  = //这个部分在其他模块中使用
        $output->EduData =
        $output->dataList = Libs_DBHelper::getList($commonOption);
        if('preView' == $output->pageType ){
             return $output->fetchCol('Plugin/MyResume/Preview/EduInfo');
        }else{
            return $output->fetchCol('Plugin/MyResume/EduInfo');
        }
    }
    public static function getPositionInfo(ME_Request $input, ME_Response $output)
    {

        $resumeDb = Db_Resume::instance();
        $commonOption = array(
                'db'        => $resumeDb,
                'fromSql'   => 'from resume_position ',
                'whereSql'  => "where uid = {$input->uid}",
                'onlyData'  => true,
                'debug'     => false,
        );
        $output->PositionData =
        $output->dataList = Libs_DBHelper::getList($commonOption);

        if('preView' == $output->pageType ){
             return $output->fetchCol('Plugin/MyResume/Preview/PositionInfo');
        }else{
            return $output->fetchCol('Plugin/MyResume/PositionInfo');
        }
    }
    public static function getSchoolAwardInfo(ME_Request $input, ME_Response $output)
    {

        $resumeDb = Db_Resume::instance();
        $commonOption = array(
                'db'        => $resumeDb,
                'fromSql'   => 'from resume_reward ',
                'whereSql'  => "where uid = {$input->uid}",
                'onlyData'  => true,
                'debug'     => false,
        );

        $output->SchoolAwardData =
        $output->dataList = Libs_DBHelper::getList($commonOption);

        if('preView' == $output->pageType ){
             return $output->fetchCol('Plugin/MyResume/Preview/SchoolAwardInfo');
        }else{
            return $output->fetchCol('Plugin/MyResume/SchoolAwardInfo');
        }
    }
    public static function getOtherInfo(ME_Request $input, ME_Response $output)
    {

        $resumeDb = Db_Resume::instance();
        $commonOption = array(
                'db'        => $resumeDb,
                'fromSql'   => 'from resume_other',
                'whereSql'  => "where uid = {$input->uid}",
                'onlyData'  => true,
                'debug'     => false,
        );
        $output->OtherData =
        $output->dataList  = Libs_DBHelper::getList($commonOption);
        if('preView' == $output->pageType ){
             return $output->fetchCol('Plugin/MyResume/Preview/OtherInfo');
        }else{
            return $output->fetchCol('Plugin/MyResume/OtherInfo');
        }
    }
    public static function getLanguageInfo(ME_Request $input, ME_Response $output)
    {

        $resumeDb = Db_Resume::instance();
        $commonOption = array(
                'db'        => $resumeDb,
                'fromSql'   => 'from resume_language',
                'whereSql'  => "where userid = {$input->uid}",
                'onlyData'  => true,
                'debug'     => false,
        );
        $output->langData =
        $output->dataList = Libs_DBHelper::getList($commonOption);

        $langArr = Libs_Admin_Category::getCategoryList(array("module_type"=>2,"type"=>1));
        if(!empty ($langArr) && is_array($langArr)){
            foreach ($langArr as $val){
                $languageArr[$val['classid']] = $val['name'];
            }
        }
        $output->languageArr = $languageArr;

        $gradeArr = Libs_Admin_Category::getCategoryList(array("module_type"=>2,"type"=>2));
        if(!empty ($gradeArr) && is_array($gradeArr)){
            foreach ($gradeArr as $val){
                $gArr[$val['classid']][$val['subclassid']] = $val['name'];
            }
        }
        $output->gArr = $gArr;

        if('preView' == $output->pageType ){
             return $output->fetchCol('Plugin/MyResume/Preview/LanguageInfo');
        }else{
            return $output->fetchCol('Plugin/MyResume/LanguageInfo');
        }
    }
    public static function getProjectInfo(ME_Request $input, ME_Response $output)
    {

        $resumeDb = Db_Resume::instance();
        $commonOption = array(
                'db'        => $resumeDb,
                'fromSql'   => 'from resume_project',
                'whereSql'  => "where userid = {$input->uid}",
                'onlyData'  => true,
                'debug'     => false,
        );
        $dataList = Libs_DBHelper::getList($commonOption);
        if(!empty($dataList) && is_array($dataList)){
            foreach ($dataList as $datakey => $dataval) {
                $tonow = $dataval['tonow'];
                if($tonow == 0){
                    $enddate = $dataval['endyear'].'-'.$dataval['endmonth'];
                }else{
                    $enddate = '今';
                }
                $dataList[$datakey]['attendTime'] = $dataval['startyear'].'-'.$dataval['startmonth'].'至'.$enddate;
            }
        }
        $output->projectData =
        $output->dataList = $dataList;

        #团队规模
        $config = ME_Config::get("MyResume");
        $output->teamsize = $config['teamsize'];

        if('preView' == $output->pageType ){
             return $output->fetchCol('Plugin/MyResume/Preview/ProjectInfo');
        }else{
            return $output->fetchCol('Plugin/MyResume/ProjectInfo');
        }
    }
    /**
     *  获取工作经历的添加状态信息
     * @param ME_Request $input
     * @param ME_Response $output
     * @return <type>
     */
    public static function getJobInfo(ME_Request $input, ME_Response $output)
    {

        $resumeDb = Db_Resume::instance();
        $commonOption = array(
                'db'        => $resumeDb,
                'fromSql'   => 'from resume_job',
                'whereSql'  => "where userid = {$input->uid}",
                'onlyData'  => true,
                'debug'     => false,
        );

        $dataList = Libs_DBHelper::getList($commonOption);
        if(!empty($dataList) && is_array($dataList)){
            foreach ($dataList as $datakey => $dataval) {
                $onjob = $dataval['onjob'];
                if($onjob == 0){
                    $enddate = $dataval['endyear'].'-'.$dataval['endmonth'];
                }else{
                    $enddate = '今';
                }
                $dataList[$datakey]['onjobtime'] = $dataval['startyear'].'-'.$dataval['startmonth'].'至'.$enddate;
            }
        }
        $output->jobData =
        $output->dataList = $dataList;

        if('preView' == $output->pageType ){
             return $output->fetchCol('Plugin/MyResume/Preview/JobInfo');
        }else{
            return $output->fetchCol('Plugin/MyResume/JobInfo');
        }
    }

    /**
     *  获取求职经历的添加状态信息
     * @param ME_Request $input
     * @param ME_Response $output
     * @return <type>
     */
    public static function getJobHistoryInfo(ME_Request $input, ME_Response $output)
    {

        $resumeDb = Db_Resume::instance();
        $commonOption = array(
                'db'        => $resumeDb,
                'fromSql'   => 'from resume_jobhistory',
                'whereSql'  => "where userid = {$input->uid}",
                'onlyData'  => true,
                'debug'     => false,
        );
	$offerData = 
        $dataList = Libs_DBHelper::getList($commonOption);
        if(!empty($dataList) && is_array($dataList)){
            foreach ($dataList as $datakey => $dataval) {
                $dataList[$datakey]['gettime'] = $dataval['getyear'].'-'.$dataval['getmonth'];
            }
        }
	$output->offerData = 
        $output->dataList = $dataList;

        //求职类型键值对应
        $config = ME_Config::get("MyResume");
        $output->jobhistorytype = $config['jobhistorytype'];


        if('preView' == $output->pageType ){
             return $output->fetchCol('Plugin/MyResume/Preview/JobHistoryInfo');
        }else{
            return $output->fetchCol('Plugin/MyResume/JobHistoryInfo');
        }
    }

    /**
     *  获取求职经历的添加状态信息
     * @param ME_Request $input
     * @param ME_Response $output
     * @return <type>
     */
    public static function getTrainInfo(ME_Request $input, ME_Response $output)
    {

        $resumeDb = Db_Resume::instance();
        $commonOption = array(
                'db'        => $resumeDb,
                'fromSql'   => 'from resume_train',
                'whereSql'  => "where userid = {$input->uid}",
                'onlyData'  => true,
                'debug'     => false,
        );

        $dataList = Libs_DBHelper::getList($commonOption);
        if(!empty($dataList) && is_array($dataList)){
            foreach ($dataList as $datakey => $dataval) {
                $tonow = $dataval['tonow'];
                if($tonow == 0){
                    $enddate = $dataval['endyear'].'-'.$dataval['endmonth'];
                }else{
                    $enddate = '今';
                }
                $dataList[$datakey]['traintime'] = $dataval['startyear'].'-'.$dataval['startmonth'].'至'.$enddate;
            }
        }
        $output->trainingData =
        $output->dataList = $dataList;

        if('preView' == $output->pageType ){
             return $output->fetchCol('Plugin/MyResume/Preview/TrainInfo');
        }else{
            return $output->fetchCol('Plugin/MyResume/TrainInfo');
        }
    }


    /**
     *  获取证书的添加状态信息
     * @param ME_Request $input
     * @param ME_Response $output
     * @return <type>
     */
        public static function getCertInfo(ME_Request $input, ME_Response $output)
    {

        $resumeDb = Db_Resume::instance();
        $commonOption = array(
                'db'        => $resumeDb,
                'fromSql'   => 'from resume_cert',
                'whereSql'  => "where userid = {$input->uid}",
                'onlyData'  => true,
                'debug'     => false,
        );

	$output->certData = 
        $dataList = Libs_DBHelper::getList($commonOption);
        $output->dataList = $dataList;

        if('preView' == $output->pageType ){
             return $output->fetchCol('Plugin/MyResume/Preview/CertInfo');
        }else{
            return $output->fetchCol('Plugin/MyResume/CertInfo');
        }
    }

    /**
     *  获取证书的添加状态信息
     * @param ME_Request $input
     * @param ME_Response $output
     * @return <type>
     */
    public static function getITInfo(ME_Request $input, ME_Response $output)
    {

        $resumeDb = Db_Resume::instance();
        $commonOption = array(
                'db'        => $resumeDb,
                'fromSql'   => 'from resume_it',
                'whereSql'  => "where userid = {$input->uid}",
                'onlyData'  => true,
                'debug'     => false,
        );

        $dataList = Libs_DBHelper::getList($commonOption);
	$output->itskillData = 
        $output->dataList = $dataList;

        #技能键值对应
        $config = ME_Config::get("MyResume");
        $output->itSkill_k_v = $config['itSkill_k_v'];

        if('preView' == $output->pageType ){
             return $output->fetchCol('Plugin/MyResume/Preview/ITInfo');
        }else{
            return $output->fetchCol('Plugin/MyResume/ITInfo');
        }
    }

}
?>
